package com.example.questionnaires.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.questionnaires.common.Result;
import com.example.questionnaires.common.PageResult;
import com.example.questionnaires.entity.ForumPost;
import com.example.questionnaires.mapper.ForumPostMapper;
import com.example.questionnaires.service.ForumPostService;
import org.springframework.stereotype.Service;

@Service
public class ForumPostServiceImpl extends ServiceImpl<ForumPostMapper, ForumPost> implements ForumPostService {
    @Override
    public Result<PageResult<ForumPost>> list(Integer page, Integer size) {
        Page<ForumPost> pageParam = new Page<>(page, size);
        Page<ForumPost> pageResult = this.page(pageParam);
        return Result.success(PageResult.build(
            pageResult.getRecords(),
            pageResult.getTotal(),
            pageResult.getSize(),
            pageResult.getCurrent()
        ));
    }
} 